<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<script>
		//数组二分
		var num=Number(prompt('输入1到10之间的数字'));
		var arr=[1,2,3,4,5,6,7,8,9,10];
		var minIndex=0;
		var maxIndex=arr.length;
		var midIndex=parseInt(minIndex+maxIndex)/2;
		while(true){
			if(num==arr[midIndex]){
				console.log('输入数字的位置在'+midIndex);
			}else if(num>arr[midIndex]){
				minIndex=midIndex;
				midIndex=parseInt((minIndex+maxIndex)/2);
			}else{
				maxIndex=midIndex;
				midIndex=parseInt((minIndex+maxIndex)/2);
			}
		}
	</script>
</head>
<body>
	
</body>
</html>